import Vue from 'vue'
import App from './App'

Vue.config.productionTip = false

App.mpType = 'app'

import store from './store'

import tips from "./common/tips.js"
Vue.prototype.$tips = tips

import common from "./common/common.js"
Vue.prototype.$common = common

import request from "./common/request.js"
Vue.prototype.$request = request

import config from "./config.js"
Vue.prototype.$config = config

const app = new Vue({
	store,
	...App
})



const go = (url, data) => {
	if (data) {
		let vo = JSON.stringify(data);
		url += '?vo=' + vo
	}
	uni.navigateTo({
		url: url
	})
}

const gotab = url => {
	console.log(url);
	uni.switchTab({
		url: url
	})
}

const success = res => {
	if (res.status == 'success') {
		return true
	}
	return false
}

const isLogin = res => {
	uni.showModal({
		title: '您还未登录',
		content: '点击登录,登录后可查看更多!',
		showCancel: true,
		confirmText: '登录',
		success: (res) => {
			// console.log(res);
			if (res.confirm) {
				uni.navigateTo({
					url: "/pages/index/wxLogin"
				})
			} else if (res.cancel) {
				console.log('用户点击取消');
				return false;
			}
		}
	});
	
}

// const url = '39.104.60.125:8888';
const templateId = ['9GiwHzjyo5fqLE5DH-I91zwV-vnQzFsSNv9B5BbHAGA'];

const baseUrl = config.API
Vue.prototype.$g = {
	go,
	gotab,
	success,
	templateId,
	baseUrl,
	isLogin,
};

app.$mount()
